package cn.zxyh.service.impl;

import java.util.List;

import javax.annotation.Resource;

import cn.zxyh.mapper.BankCardMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.zxyh.mapper.UserMapper;
import cn.zxyh.pojo.User;
import cn.zxyh.service.Userservice;

/**
 * @author Administrator
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class Userserviceimpl implements Userservice {
	@Resource
	private UserMapper userMapper;
	@Resource
	private BankCardMapper bankCardMapper;


	@Override
	public void addUser(User u) {
		userMapper.addUser(u);
	}

	@Override
	public List<User> findAll() {
		return userMapper.findAll();
	}

	@Override
	public User findById(User user) {
		return userMapper.findById(user);
	}

	@Override
	public int updateUser(User user) {
		return userMapper.updateUser(user);
	}

	@Override
	public int modifyBankCard(User user) {
		int result = userMapper.updateUser(user);
		if (result == 0)
			return 0;
		else {
			return bankCardMapper.updateCard(user);
		}
	}
}
